﻿<?php
	session_start();
	
	// Clear all previous messages.
	if($_SESSION['log-err']) session_unregister('log-err');
	if($_SESSION['log-info']) session_unregister('log-info');
	
	// Loading submitted parameters.
	$userName = $_POST['userName']; 
	$userPassword = $_POST['userPassword'];
	
	// Make the default page to the login	
	$_SESSION['page'] = "login.php";

	// Check for completion of mandatory fields.
	if($userName == "" || $userPassword == ""){
		$_SESSION['log-err'] = "පරිශීලක නාමය හෝ මුරපදය නොගැලපේ.";
	}
	
	// Check for super admin login.
	if($userName == "superAdmin" && $userPassword == "superAdmin"){
		$_SESSION['page'] = "home.php";
	}else{		
		$_SESSION['log-err'] = "පරිශීලක නාමය හෝ මුරපදය නොගැලපේ.";
	}
	
	header('Location: ../');		
?>